﻿using UnityEditor;
using UnityEditor.AnimatedValues;

namespace EditorExtension
{
    public class EditorGUILayoutAPI
    {
        private BuildTargetGroup mBuildTargetGroup = BuildTargetGroup.Unknown;
        private AnimBool mAnimBool = new AnimBool();
        private bool mFoldoutHeaderGroup = false;
        
        private bool mToggleGroup = false;
        private bool mToggle1Value = false;
        private bool mToggle2Value = true;
        
        public void Draw()
        {
            // 开关
            mAnimBool.value = EditorGUILayout.ToggleLeft("Open Fade Group", mAnimBool.value);
            
            // 折叠组
            mFoldoutHeaderGroup = EditorGUILayout.BeginFoldoutHeaderGroup(mFoldoutHeaderGroup, "FoldoutHeaderGroup");
            if (mFoldoutHeaderGroup)
            {
                EditorGUILayout.BeginFadeGroup(mAnimBool.faded);
                if(mAnimBool.target)
                {
                    // 显示可构建的目标平台
                    mBuildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();
                    EditorGUILayout.EndBuildTargetSelectionGrouping();
                }
                EditorGUILayout.EndFadeGroup();
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            // 开关组
            mToggleGroup = EditorGUILayout.BeginToggleGroup("全部设置", mToggleGroup);
            {
                mToggle1Value = EditorGUILayout.Toggle(mToggle1Value);
                mToggle2Value = EditorGUILayout.Toggle(mToggle2Value);
            }
            EditorGUILayout.EndToggleGroup();

        }
    }
}